package com.own.business.exam.entity.bo;


import com.own.business.exam.entity.po.Exam;
import com.own.component.common.base.entity.BaseBo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * ExamBo
 *
 * @author chenxueli
 * @date 2021/05/18 14:24:25
 */
@Schema(title = "考试表" + ConstantBeanSuffix.BO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class ExamBo extends BaseBo<Exam> {

    @Schema(title = "考试标题")
    private String title;

    @Schema(title = "开始时间")
    private LocalDateTime startTime;

    @Schema(title = "结束时间")
    private LocalDateTime endTime;

    @Schema(title = "满分分数")
    private BigDecimal fullScore;

    @Schema(title = "是否指定人数 1=指定 0=不指定")
    private Integer isAssignNumber;

    @Schema(title = "考试最多容纳的人数 0表示不做限制")
    private Integer assignNumber;

    @Schema(title = "是否可以重复作答 1=可以 0=不可以")
    private Integer isRepeat;

    @Schema(title = "是否需要自定义分数 1=需要 0=不需要")
    private Integer isCustomerRank;

    @Schema(title = "是否直接判题验卷 1=是 0=不是")
    private Integer isDirectJudge;

    @Schema(title = "考试时间结束之后是否可以交卷 1=可以 0=不可以")
    private Integer isHandPaperAfterTime;

    @Schema(title = "考生查看考试答案的时机 1=交卷之后 2=指定时间 3=无法查看")
    private Integer viewAnswerType;

    @Schema(title = "查看试卷答案的时间")
    private LocalDateTime viewAnswerTime;

    @Schema(title = "考试类型 1=普通考试 2=实名考试 3=...")
    private Integer type;

    /**
     * 转持久化对象
     *
     * @param entity 原持久化对象
     * @return 持久化对象
     */
    @Override
    public Exam toPo(Exam entity) {
        if (entity == null) {
            entity = new Exam();
        }
        entity.setTitle(title);
        entity.setStartTime(startTime);
        entity.setEndTime(endTime);
        entity.setFullScore(fullScore);
        entity.setIsAssignNumber(isAssignNumber);
        entity.setAssignNumber(assignNumber);
        entity.setIsRepeat(isRepeat);
        entity.setIsCustomerRank(isCustomerRank);
        entity.setIsDirectJudge(isDirectJudge);
        entity.setIsHandPaperAfterTime(isHandPaperAfterTime);
        entity.setViewAnswerType(viewAnswerType);
        entity.setViewAnswerTime(viewAnswerTime);
        entity.setType(type);
        return super.toPo(entity);
    }

}
